package com.appspot.categoryeditor.controller;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;

import com.appspot.categoryeditor.utils.UrlUtils;
import com.appspot.categoryeditor.utils.UserUtils;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

public class LoginController extends Controller{
	@Override
	public Navigation run() throws Exception {
		
		UserService userService = UserServiceFactory.getUserService();
		
		if (!UserUtils.checkLogin(request)) {
			response.sendRedirect(userService.createLoginURL(request.getRequestURI()));
			return null;
		}else{
			String userid = UserUtils.getLoginUserId();
			return redirect(UrlUtils.createUserPageUrl(userid));
		}


	}
	
	

}
